package com.ruoyi.summarize.service.impl;

import com.ruoyi.summarize.mapper.SummarizeMapper;
import com.ruoyi.summarize.model.*;
import com.ruoyi.summarize.service.ISummarizeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SummarizeServiceImpl implements ISummarizeService {
    @Autowired
    private SummarizeMapper summarizeMapper;

    @Override
    public Summarize listSummarize(Long pid) {
        Summarize summarize = summarizeMapper.listSummarize(pid);
        if (summarize==null){
            summarizeMapper.insertSummarize(pid);
            return summarizeMapper.listSummarize(pid);
        }
        return summarize;
    }

    @Override
    public boolean updateSummarize(Summarize summarize) {
        //初始化数据
        summarizeMapper.insertSummarize(summarize.getProjectId());
        if (!summarize.isNull())
            summarizeMapper.updateSummarize(summarize);
        return true;
    }

    @Override
    public boolean checkFinish(Long pid) {
        Integer i = summarizeMapper.selectFinishByPid(pid);
        if (i==null)
            return false;
        return i==1;
    }
}
